f=file("18.txt","r")
S=f.read()
f.close()
S=S.split("\n")
S=[map(int,i.split()) for i in S]  
for i in xrange(14):
    for j in xrange(14-i):
            S[13-i][j]+=max(S[13-i+1][j],S[13-i+1][j+1])
print S[0][0]

        
        
    
    
